
# https://github.com/gaoxiang12/slam_in_autonomous_driving

## depends
sudo apt install -y ros-noetic-pcl-ros ros-noetic-velodyne-msgs libopencv-dev libgoogle-glog-dev libeigen3-dev libsuitesparse-dev libpcl-dev libyaml-cpp-dev libbtbb-dev libgmock-dev

thirdparty_dir="/home/xxty/trobot/trobot_ros/thirdparty/"
rm -rf $thirdparty_dir/Pangolin/build
rm -rf $thirdparty_dir/g2o/build
rm -rf /home/xxty/trobot/trobot_ros/slam_ws/src/slam_in_autonomous_driving/build

## Pangolin
## git clone https://github.com/stevenlovegrove/Pangolin.git
# cd thirdparty/
# unzip Pangolin.zip
# cd Pangolin

cd $thirdparty_dir/Pangolin/
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig

## g2o
# cd thirdparty/g2o/
cd $thirdparty_dir/g2o/
mkdir build && cd build
cmake ..
make
sudo make install
sudo ldconfig

# build books
# cd slam_in_autonomous_driving
cd /home/xxty/trobot/trobot_ros/slam_ws/slam_in_autonomous_driving
mkdir build && cd build
cmake ..
make 


# 如果使用/home/xxty/trobot/trobot_ros/thirdparty  需要修改slam_in_autonomous_driving/cmake/packages.cmake文件
# SET(TROBOT_ROS /home/xxty/trobot/trobot_ros)
# #sophus
# include_directories(${TROBOT_ROS}/thirdparty/sophus)
# # g2o 使用thirdparty中的
# include_directories(${TROBOT_ROS}/thirdparty/g2o/)
# set(g2o_libs
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_stuff.so
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_core.so
# 	# ${PROJECT_SOURCE_DIR}/thirdparty/g2o/lib/libg2o_solver_cholmod.so
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_solver_dense.so
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_solver_csparse.so
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_csparse_extension.so
#         ${TROBOT_ROS}/thirdparty/g2o/lib/libg2o_types_sba.so
#         ${CSPARSE_LIBRARY}
#         ${CHOLMOD_LIBRARY}
#         )

# running test
# cd slam_in_autonomous_driving
# ./bin/test_2d_mapping --bag_path=/home/xxty/bags/2dmapping/floor1.bag with_loop_closing=true
# ./bin/test_2d_mapping --bag_path=/home/xxty/bags/3901_0928.bag --with_loop_closing=false --scan_topic="/scan_raw"



